home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / text / faqs / tcl-faq.part2 < prev    next >
Encoding:
Internet Message Format  |  1994-04-21  |  58.7 KB

  1. Subject: FAQ: comp.lang.tcl Frequently Asked Questions (2/5)
  2. Newsgroups: comp.lang.tcl,comp.answers,news.answers
  3. From: lwv26@cas.org (Larry W. Virden)
  4. Date: Wed, 20 Apr 1994 17:43:48 GMT
  5.  
  6. Archive-name: tcl-faq/part2
  7. Version: 5.0
  8. Last-modified: April 20, 1994
  9.  
  10. Please do not be offended if I neglect to acknowledge your contribution
  11. to this FAQ!  I sometimes forget to put an attribution in.  I especially
  12. try to add them if it appears that there is further experimentation or
  13. debugging being done though.
  14.  
  15.     For more information concerning Tcl (see "tcl-faq/part1"),
  16. (see "tcl-faq/part3"), (see "tcl-faq/part4"), or (see "tcl-faq/part5").
  17.  
  18. Index of questions:
  19.  
  20. VIII. Questions on building Tcl and friends on your system:
  21.     Q8A. Is there anywhere I can find help with the details of getting 
  22.         Tcl to work on my machine?
  23.     Q8B. Why does the link step says that some of the functions Tcl,
  24.         needs are missing when I am trying to build it?
  25.     Q8C. Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  26.     Q8D. Has anyone gotten Tcl to compile under HP-UX?
  27.     Q8E. Has anyone gotten Tcl to compile under VMS?
  28.     Q8F. What does it take to get Tcl to compile under SCO Unix?
  29.     Q8G. Why do I get format and scan errors when I run tclTest
  30.         (NeXT, AIX, etc.)?
  31.     Q8H. Why do I get lots of errors under Irix 4.0.1 when I run
  32.         tclTest?
  33.     Q8I. Does anyone else have problems with Tcl on a Cray?
  34.     Q8J. Does anyone know how to get Tk to run on a SparcBook or other
  35.         laptop with a limited number of colors?
  36.     Q8K. What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  37.         or other POSIX/ANSI C systems not already supported?
  38.     Q8L. Why do I get a parse error in tkInit.c when I try to compile
  39.         Tk on my Irix machine?
  40.     Q8M. What do I need to do to install Tcl 7.x/Tk 3.x on NeXTSTEP 3.1?
  41.     Q8N. Why can't I print the draft of the Tcl/Tk book?
  42.     Q8O. Why am I getting errors on my SGI Indigo workstation?
  43.     Q8P. How do I build expect on Solaris 2.3?
  44.     Q8Q. How do I add BLT to a TclX/Tk ?
  45.  
  46. IX.  How, in Tcl, can I XXX:
  47.     Q9A. get association lists or property lists?
  48.     Q9B. call one proc with the multi parameter value returned by 
  49.         another proc?
  50.     Q9C. pass an array into a proc?
  51.     Q9D. pipe output of a command back into a Tcl parsing procedure?
  52.     Q9E. merge extended Tcl into other programs such as wish or expect?
  53.     Q9F. delete a procedure from within a script?
  54.     Q9G. get parray to recognize an array variable I have created
  55.         via upvar?
  56.     Q9H. get more than 7 digits of double precision?
  57.     Q9I. grab the command line whenever a non-built-in call is made?
  58.     Q9J. get or set an environment variable?
  59.     Q9K. use numbers with leading zeroes?
  60.     Q9L. find the command line arguments to my application?
  61.     Q9M. put comments in my script, for example in a case statement?
  62.     Q9N. redirect stdin or stdout safely, including binary data?
  63.     Q9O. trap signals, and other more Unix specific functions?
  64.     Q9P. get quoted strings to work the way I want?
  65.     Q9Q. share procedures between multiple tcl applications?
  66.     Q9R. get items inserted into a list?
  67.     Q9S. perform a non-blocking read on a file identifier?
  68.     Q9T. read and write from a pipe without locking up?
  69.  
  70. X.  How, in Tk, can I XXX:
  71.     A. Question on starting Tk applications
  72.  
  73.     Q10.A.1. get my wish application to execute - I just get a wish prompt!
  74.     Q10.A.2. ,using a machine with less than 8 bit color, run?
  75.     Q10.A.3. set X11 resources for a wish application in an 
  76.         app-defaults file?
  77.     Q10.A.4. specify bitmap patterns on the command line instead of 
  78.         as a file name?
  79.     Q10.A.5. get a Motif user interface?
  80.     Q10.A.6. get an OpenLook user interface?
  81.     Q10.A.7. get Tk 3.3 to even start - I get security error messages.
  82.  
  83.     B. Questions on Tk applications and the keyboard
  84.  
  85.     Q10.B.1. change the default class bindings?
  86.     Q10.B.2. delete a binding?
  87.     Q10.B.3. change a binding while it is being executed?
  88.     Q10.B.4. bind the arrow key on my Sun keyboard?
  89.     Q10.B.5. get root's mouse bindings to work in my Tk application?
  90.  
  91.     C. Questions on Tk and X11 interactions
  92.  
  93.     Q10.C.1. get an application to also use libXt?
  94.     Q10.C.2. change the X11 cursor?
  95.     Q10.C.3. raise or lower a window?
  96.     Q10.C.4. re-map a withdrawn window id?
  97.     Q10.C.5. use Tk in a subwindow of a non-Tk X11 application?
  98.     Q10.C.6. bind <Enter> and <Leave> to a frame containing other widgets?
  99.     Q10.C.7. mix interactions between Xt and Tk/Tcl?
  100.  
  101.     D. Questions on Tk listboxes
  102.  
  103.     Q10.D.1. resize a listbox?
  104.     Q10.D.2. select two items that are not adjacent in the listbox at 
  105.         one time?
  106.     Q10.D.3. select items in more than one Tk listbox at a time?
  107.     Q10.D.4. avoid fractional white space at the end of a resizable listbox?
  108.  
  109.     E. Questions on Tk canvases
  110.  
  111.     Q10.E.1. get output from a Tk canvas?
  112.     Q10.E.2. fill a canvas which is bounded by lines as opposed to a
  113.         shape like a polygon, oval, etc.?
  114.     Q10.E.3. raise/lower canvas window objects or draw graphics onto a 
  115.         window object inside a canvas?
  116.     Q10.E.4. detect when the canvas has been resized?
  117.  
  118.     F. Other questions
  119.  
  120.     Q10.F.1. get the name of my own interpreter?
  121.     Q10.F.2. get -relief to work on my text widgets?
  122.     Q10.F.3. create a scrollable window of buttons?
  123.     Q10.F.4. pack a text widget so that it can be resized interactively?
  124.     Q10.F.5. create a widget with an upper case name?
  125.     Q10.F.6. create equal sized buttons?
  126.     Q10.F.7. vertically stack radio buttons aligning regardless of font?
  127.     Q10.F.8. initialize an entry widget with some text?
  128.  
  129. End of FAQ Index
  130.  
  131. ----------------------------------------------------------------------
  132.  
  133. ------------------------------
  134.  
  135. From: -VIII- Questions on building Tcl and friends on your system
  136. Subject: -Q8A- Is there anywhere I can find help with the details of 
  137.         getting Tcl to work on my machine?
  138.  
  139. A8A. Glad you asked!  Look in the Tcl distribution for the file called
  140. "porting.notes".  This will contain a collection of notes that various people
  141. have provided about porting Tcl to various machines and operating systems.
  142. There are also a file called "README" which should be read FIRST - before
  143. doing anything else with the code (this should always be one's first
  144. step with any package).  Finally, there is a "changes" file which details
  145. what has changed since the last release - be sure to read this to see
  146. what might need to change in your programs.
  147.  
  148. ------------------------------
  149.  
  150. From: -VIII- Questions on building Tcl and friends on your system
  151. Subject: -Q8B- Why does the link step says that some of the functions Tcl,
  152.         needs are missing when I am trying to build it?
  153.  
  154. A8B. Did you run the "config" program first, by doing a "csh ./config" or
  155. equivalent?  Without doing this, things such as strtoul or strerror
  156. are sometimes mentioned as missing.
  157.  
  158. Tcl includes equivalents for at least the following functions and include files
  159. which may not be found on some systems:
  160.  
  161. dirent.h       limits.h          stdlib.h         string.h
  162.  
  163. opendir.c      strerror.c     strstr.c         strtol.c        strtoul.c
  164.  
  165. strtod.c
  166.  
  167. ------------------------------
  168.  
  169. From: -VIII- Questions on building Tcl and friends on your system
  170. Subject: -Q8C- Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  171.  
  172. A8C. See porting notes - especially the note about strtoul.
  173.  
  174. One user got Tcl to compile with a few minor source modifications
  175. (for example, duplicate case statements for errno and signal symbols in 
  176. tclUnixStr.c). 
  177.  
  178. A few other problems arose in the tests.  One is caused by AIX printf
  179. not formatting %#x and %#o correctly when the value to be printed is
  180. zero:  they print "0x0" and "00" instead of "0" and "0" respectively.
  181. This was reported as not a problem in earlier releases.  No fixes have
  182. been posted.
  183.  
  184. Finally, a problem occurs in open.test.  test 13.6 hangs because "cat"
  185. on the RS6000 is unbuffered.  A workaround is to change the execution
  186. of "cat" in open.test to do a "cat -u".
  187.  
  188. Dov Grobgeld <dov@menora.weizmann.ac.il> provided info on creating Tcl
  189. and Tk shared libraries under AIX 3.1.5:
  190.  
  191. For Tcl:
  192.  
  193. cc -o tkshar.o *.o -bE:tclshar.exp -bM:SRE -berok -lX11 -lm
  194. ar r libtclshr tclshar.o
  195.  
  196. For Tk:
  197.  
  198. cc -o tkshar.o *.o -bE:tkshar.exp -bM:SRE -berok -Ltcl -lX11 -lm -ltclshr
  199. ar r libtkshr tkshar.o
  200.  
  201. where tckshar.exp and tkshar.exp had lists of the external functions.
  202.  
  203. There are also problems with fonts on AIX and the IBM.  A patch is needed
  204. from IBM to fix the X server so that fonts are working
  205.  
  206. ------------------------------
  207.  
  208. From: -VIII- Questions on building Tcl and friends on your system
  209. Subject: -Q8D- Has anyone gotten Tcl to compile under HP-UX?
  210.  
  211. A8D. See the porting notes.
  212.  
  213. ------------------------------
  214.  
  215. From: -VIII- Questions on building Tcl and friends on your system
  216. Subject: -Q8E- Has anyone gotten Tcl to compile under VMS?
  217.  
  218. A8E. Information from jkimball@src.honeywell.com (John Kimball) on
  219. May 4, 1993 was that he had gotten Tcl 6.7 and Tk 3.2 ported to VMS
  220. 5.5.  See the catalog for the file information.
  221.  
  222. ------------------------------
  223.  
  224. From: -VIII- Questions on building Tcl and friends on your system
  225. Subject: -Q8F- What does it take to get Tcl to compile under SCO Unix?
  226.  
  227. A8F. Add a "#undef select" to tkEvent.c, and remove the reference to 
  228. TK_EXCEPTION around line 460 of main.c.
  229.  
  230. Tk uses its own scheme for allocating the border colors for its 3D
  231. widgets, which causes problems when running TK on a system with
  232. "PseudoColor" display class, and a 16-cell colormap.
  233.  
  234. If you can't go to eight bitplanes, you can instead start the server
  235. with a "-static" (Xsco) or "-analog" (Xsight) option, making the
  236. display class become "StaticColor".  This makes the entire colormap
  237. read-only, and it will return the color that most closely maps to the
  238. desired color as possible.
  239.  
  240. This information is from Keith Amann <Keith_Amann@stortek.com>
  241.  
  242. ------------------------------
  243.  
  244. From: -VIII- Questions on building Tcl and friends on your system
  245. Subject: -Q8G- Why do I get format and scan errors when I run tclTest
  246.         (NeXT, AIX, etc.)?
  247.  
  248. A8G. That's a problem (scanf/printf) many systems seem to have.  Don't
  249. worry too much about it - just don't use these 'advanced' features.  If
  250. you're hacking C, you'll have the same problems.
  251.  
  252. ------------------------------
  253.  
  254. From: -VIII- Questions on building Tcl and friends on your system
  255. Subject: -Q8H- Why do I get lots of errors under Irix 4.0.1 when I run
  256.         tclTest?
  257.  
  258. A8H. There's a bug in the 4.0.1 optimizer that's fixed in 4.0.2.
  259. Compile tclVar.c using -O0 (no optimization).
  260.  
  261. ------------------------------
  262.  
  263. From: -VIII- Questions on building Tcl and friends on your system
  264. Subject: -Q8I- Does anyone else have problems with Tcl on a Cray?
  265.  
  266. A8I. See the porting notes for a set of changes mentioned.  Also,
  267. Booker C. Bense <benseb@grumpy.sdsc.edu> reports that version 3.0.1.6
  268. has some real problems with char pointers, causing Tcl to crash.  Using
  269. version 3.0.2.1, things are much better, except for a minor formatting
  270. problem and serious problems with scan.
  271.  
  272. ------------------------------
  273.  
  274. From: -VIII- Questions on building Tcl and friends on your system
  275. Subject: -Q8J- Does anyone know how to get Tk to run on a SparcBook or other
  276.         laptop with a limited number of colors?
  277.  
  278. A8J. On a SparcBook, if you start openwin (the OpenWindows server starting
  279. command) as:
  280.  
  281. openwin -dev "/dev/fb staticvis"
  282.  
  283. you get a static visual color model that Tk copes with better than the
  284. default.  Some things are ugly, but not as ugly as monochrome.
  285.  
  286. ------------------------------
  287.  
  288. From: -VIII- Questions on building Tcl and friends on your system
  289. Subject: -Q8K- What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  290.         or other Posix/ANSI C systems not already supported?
  291.  
  292. A8K. Patches for 386BSD were posted to comp.lang.tcl back in Nov. 1992 to
  293. alt.sources.  See one of the ftp archive sites for this group for them.
  294. Basically, there were some setting of defines and a few places where 
  295. const char * had to be used in place of char *.  
  296.  
  297. ------------------------------
  298.  
  299. From: -VIII- Questions on building Tcl and friends on your system
  300. Subject: -Q8L- Why do I get a parse error in tkInit.c when I try to compile
  301.         Tk on my Irix machine?
  302.  
  303. A8L. Jon Knight <J.P.Knight@loughborough.ac.uk> reports that the version of
  304. Irix that he is using doesn't define a uid_t.  One needs to define one 
  305. somewhere (or comment out the lines causing the problems) to get the compile
  306. to continue.
  307.  
  308. ------------------------------
  309.  
  310. From: -VIII- Questions on building Tcl and friends on your system
  311. Subject: -Q8M- What do I need to do to install Tcl 7.1/Tk 3.4 on NeXTSTEP 3.1?
  312.  
  313. A8M.  I have indicated in the past that this particular question seems
  314. to generate controversy - I have replaced previous explanations with the
  315. latest msg from someone who sounds authoritative...
  316.  
  317. From: Robert Nicholson <robert@steffi.demon.co.uk>
  318.  
  319. This is for TCL7.1 and TK3.4 
  320.  
  321. This is a variation on Thomas Funke's entry.
  322.  
  323. Installing TCL7.1 on NeXT
  324. =========================
  325.  
  326. To install tcl7.1 on NeXTSTEP 3.1 you must:
  327.  
  328. - run configure with predefined CPP:
  329.     type "sh" to run a Bourne shell.
  330.     then type
  331.     CPP='cc -E' ./configure
  332.  
  333. - edit Makefile:
  334.  
  335.   add tmpnam.o to COMPAT_OBJS:
  336.   COMPAT_OBJS =      getcwd.o waitpid.o strtod.o tmpnam.o
  337.  
  338. At this point you probably want to rename the all calls to strtod and
  339. tmpnam to something else in order to distinguish them from those that
  340. are supplied in the NeXT libraries libsys_a.a.  You can do this by 
  341. adding the following line to AC_FLAGS
  342.  
  343.     -Dstrtod=newstrtod -Dtmpnam=newtmpnam
  344.  
  345. and renaming the names of the definitions in the appropriate
  346. compat/*.c files.
  347.  
  348. To check everything is working correctly open a tclsh 
  349.  
  350. % expr {"0" == "+"} 
  351. 0
  352.  
  353. Using the wrong strtod function will cause this test to return 1 which
  354. is a serious error.  Ignore the precision errors.
  355.  
  356. Installing TK3.4 on NEXTSTEP 3.1
  357. ================================
  358.  
  359. There is a call to strtod in TK3.4 so you should link against
  360. ../tcl-7.1/compat/strtod.o and apply the -Dstrtod=newstrtod
  361. to AC_FLAGS in Tk also.
  362.  
  363. Note:Tk's raise test will fail when running the tvtwm window manager.
  364. Changing to either twm or even better fvwm ensures that this test will
  365. succeed. 
  366.  
  367.  
  368.  
  369. ------------------------------
  370.  
  371. From: -VIII- Questions on building Tcl and friends on your system
  372. Subject: -Q8N- Why can't I print the draft of the Tcl/Tk book?
  373.  
  374. A8N.  From ouster@cs.Berkeley.EDU (John Ousterhout):
  375.  
  376. Here's my form letter that seems to explain most of the problems people
  377. have had printing parts of the book:
  378.  
  379. Some old versions of the Transcript spooler software cannot properly
  380. handle encapsulated Postscript files within another Postscript file
  381. when they do page reversal.  They tend to garble the page structure of
  382. the file, causing an error at the point of the first EPS file.  Part
  383. II of the Tcl book has lots of EPS files embedded in it, one for
  384. each screen dump.  If your printer cannot print this file I suggest
  385. checking to see if page reversal is enabled for your printer.  If
  386. so, try asking your local system wizard to disable it for you;  this
  387. should allow the file to print.  Or, find some other way to dump the
  388. Postscript file directly to the printer without going through the
  389. spooling software (e.g. perhaps you can simply cat it to the printer's
  390. serial port).
  391.  
  392. Others have suggested:
  393.  
  394.  The embedded pictures have CR as the line separator instead of LF and
  395.  this may be causing the problem. Try translating them to LFs ...
  396.  
  397.    tr '\015' '\012' <book.p2.ps >fixedbook.p2.ps
  398.  
  399. and:
  400.  
  401.  This is not the original poster's problem but in countries using A4
  402.  paper and on a particular printer, the Dataproducts LZR1260E, the frame
  403.  size causes the printing to be stretched vertically. This happens with
  404.  other Framemaker generated documents by the way. A PS interpreter bug
  405.  no doubt. The fix is to edit the dimensions for A4 paper. This shell
  406.  script does both fixes.
  407.  
  408. #!/bin/sh
  409. cat $1 | tr '\015' '\012' | sed '/FMDOCUMENT$/s/612 792/595 842/'
  410.  
  411. ------------------------------
  412.  
  413. From: -VIII- Questions on building Tcl and friends on your system
  414. Subject: -Q8O- Why am I getting errors on my SGI Indigo workstation?
  415.  
  416. A8O. From Gordon Lack <gml4410@ggr.co.uk> we are told that
  417. the SGI c compiler has some bugs with variable arguments.
  418.  
  419. tclVar.c must be compiled with -O0 at IRIX C 4.0.1 because of a
  420. compiler bug with varargs.
  421.  
  422.    Done by placing specific rule into Makefile.
  423.  
  424. > # GGR SG needs -O0 for varargs at 4.0.1
  425. >
  426. > CC_SWITCHES0 =  -O0 -I. -I${SRC_DIR} ${AC_FLAGS} ${MATH_FLAGS} \
  427. > ${GENERIC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \
  428. > -DTCL_LIBRARY=\"${TCL_LIBRARY}\"
  429. >
  430. > tclVar.o: tclVar.c
  431. >         $(CC) -c $(CC_SWITCHES0) $<
  432.  
  433. Peter NEELIN <neelin@pet.mni.mcgill.ca> also noted that:
  434.  
  435. I get tclX 7.3a to compile on an SGI (irix 4.0.5) with the following
  436. changes to the Config.mk file:
  437.  
  438. 71c71
  439. < CFLAGS=-cckr -D__GNU_LIBRARY__
  440. ---
  441. > #CFLAGS=
  442. 106,107c106,107
  443. < TCL_PLUS_BUILD=TCL_PLUS
  444. < CCPLUS=g++
  445. ---
  446. > #TCL_PLUS_BUILD=TCL_PLUS
  447. > CCPLUS=CC
  448. 191,193c191
  449. < MAN_DIR_SEPARATOR=
  450. < LIBOBJS=strftime.o
  451. ---
  452. > #MAN_DIR_SEPARATOR=.
  453.  
  454. The -D__GNU_LIBRARY solves the srandom problem and I think that the -cckr gets
  455. around the prototype error with waitpid (it's crude, but it works).
  456. I've forgotten why I needed the strftime.
  457.  
  458. If you want the version of Config.mk that worked for me, send me mail.
  459.  
  460.  
  461.  
  462. ------------------------------
  463.  
  464. From: -IX-  How, in Tcl, can I XXX:
  465. Subject: -Q8P- How do I build expect on Solaris 2.3?
  466.  
  467. A8P. From jra@hrcms.jazz.att.com (Jeff Abramson) we are told that,
  468.  
  469. > using either SunPro cc 2.0.1 or gcc 2.5.8 with
  470. > no problems.  For SunPro I do:
  471. >  
  472. >         CC=cc ./configure --prefix=directory_of_your_choice
  473. >         make CC=cc
  474. >  
  475. > For gcc I do:
  476. >  
  477. >         CC="gcc -fwritable-strings" ./configure \
  478. >        --prefix=directory_of_your_choice
  479. >        make CC="gcc -fwritable-strings"
  480.  
  481. ------------------------------
  482.  
  483. From: -IX-  How, in Tcl, can I XXX:
  484. Subject: -Q8Q- How do I add BLT to a TclX/Tk ?
  485.  
  486. A8Q. From gah@grenache.mhcnet.att.com (George A. Howlett) we get
  487. the answer:
  488.  
  489. Instead of adding TclX to blt_wish, try it the other way.  Add
  490. BLT to wishx.  It's pretty simple.
  491.  
  492. In the file ./tksrc/tkXAppInit.c, add the a call to the BLT
  493. initialization routine right after line 116.
  494.  
  495.     if (TkX_Init(interp) == TCL_ERROR) {
  496.         return TCL_ERROR;
  497.     }
  498.     if (Blt_Init(interp) != TCL_OK)) {
  499.         return TCL_ERROR;
  500.     }
  501.  
  502. Link wishx with libBLT.a and that's it.
  503.  
  504. Others recommend the tkmkmf or make-a-wish packages.
  505.  
  506.  
  507. ------------------------------
  508.  
  509. From: -IX-  How, in Tcl, can I XXX:
  510. Subject: -Q9A- association lists or property lists?
  511.  
  512. A9A. Use Extended Tcl arrays or keyed lists.
  513.  
  514. For example, if you did a:
  515.  
  516. keylset ttyFields ttyName tty1a
  517. keylset ttyFields baudRate 57600
  518. keylset ttyFields parity strip
  519.  
  520. And then an "echo $ttyFields", you'd get:
  521.  
  522.     {ttyName tty1a} {baudRate 57600} {parity strip}
  523.  
  524. ------------------------------
  525.  
  526. From: -IX-  How, in Tcl, can I XXX:
  527. Subject: -Q9B- call one proc with the multi parameter value returned by 
  528.         another proc?
  529.  
  530. A9B. Assuming y requires multiple args and x returns multiple words, use 
  531.     Tcl's eval command :
  532.  
  533.     eval y [x]
  534.  
  535. ------------------------------
  536.  
  537. From: -IX-  How, in Tcl, can I XXX:
  538. Subject: -Q9C- pass an array into a proc?
  539.  
  540. A9C. Use upvar rather than try to use global variables when possible.  If
  541. the function is event driven, you are forced to use global variables.
  542.  
  543.  
  544. # print elements of an array
  545. proc show_array arrayName {
  546.     upvar $arrayName myArray
  547.  
  548.     foreach element [array names myArray] {
  549.        puts stdout "${arrayName}($element) =  $myArray($element)"
  550.     }
  551. }
  552.  
  553. set arval(0) zero
  554. set arval(1) one
  555. show_array arval
  556.  
  557.  
  558. To return an array from a procedures, just take the array name in as an
  559. argument, as above.  Any changes you make in the array will be made in
  560. the parent's array as well.
  561.  
  562. Extended Tcl introduces a concept called keyed lists which are arrays
  563. made out of lists of key-value pairs and can be passed by value to routines,
  564. over networks, etc.
  565.  
  566. ------------------------------
  567.  
  568. From: -IX-  How, in Tcl, can I XXX:
  569. Subject: -Q9D- pipe output of a command back into a Tcl parsing 
  570.         procedure?
  571.  
  572. A9D. For example, to grep a pattern out of a range of files, one might
  573. do:
  574.  
  575. karl@NeoSoft.com (Karl Lehenbauer) writes:
  576.  
  577. set files [glob /home/cole/stats/*]
  578.  
  579. proc parseInfo { site } {
  580.    global files
  581.  
  582. #
  583. # site is chosen from a listbox earlier
  584. #
  585.    set in [open [concat "|/usr/bin/grep $site $files"] r]
  586.  
  587.    while {[gets $in line]>-1} {
  588.       puts stderr $line
  589.    }
  590.    catch {close $in}
  591. }
  592.  
  593. One thing:  the matching strings are _not_ returned in directory order.
  594.  
  595. But what if I want to check the return code AND use the output of 
  596. the command?  kennykb@dssv01.crd.ge.com (Kevin B. Kenny) writes:
  597.  
  598. if [catch {exec ls} data] {
  599.         # The exec got an error, and $errorCode has its termination status
  600. } else {
  601.         # The exec succeeded
  602. }
  603. # In any case, `data' contains all the output from the child process.
  604.  
  605. Note that Karl Lehenbauer adds that errorCode will be a list containing
  606. three elements, the string "CHILDSTATUS", the process ID of the child,
  607. and the exit status of the child.
  608.  
  609. ------------------------------
  610.  
  611. From: -IX-  How, in Tcl, can I XXX:
  612. Subject: -Q9E- merge extended Tcl into other programs such as wish or expect?
  613.  
  614. A9E. The latest version of extended Tcl, tclX 6.7c, has been enhanced to
  615. make it easier to incorporate into applications.
  616.  
  617. ------------------------------
  618.  
  619. From: -IX-  How, in Tcl, can I XXX:
  620. Subject: -Q9F- delete a procedure from within a script?
  621.  
  622. A9F. rename procedureName ""
  623.  
  624. ------------------------------
  625.  
  626. From: -IX-  How, in Tcl, can I XXX:
  627. Subject: -Q9G- get parray to recognize an array variable I have created
  628.         via upvar?
  629.  
  630. A9G. Right now (June, 1992) upvar doesn't allow you to attach to an
  631. individual element of an array.  This is considered a bug by 
  632. Mr. Ousterhout and has been place on a bug list.
  633.  
  634. ------------------------------
  635.  
  636. From: -IX-  How, in Tcl, can I XXX:
  637. Subject: -Q9H- get more than 7 digits of double precision ?
  638.  
  639. A9H. In Tcl 6.x, modify the tclExpr.c module to use %lf instead of %g.  In
  640. Tcl 7.x, set the global variable tcl_precision instead.
  641.  
  642. ------------------------------
  643.  
  644. From: -IX-  How, in Tcl, can I XXX:
  645. Subject: -Q9I- grab the command line whenever a non-built-in call is made?
  646.  
  647. A9I. The procedure "unknown" is called automatically with arguments 
  648. containing the command and its arguments for any command that couldn't be 
  649. found.  In fact, Tcl and Extended Tcl use this feature to provide demand
  650. loaded commands, and even entire libraries.
  651.  
  652. So by modifying the unknown procedure you can provide your own extended
  653. functionality, or even remove the demand loading capability if you so
  654. desire.
  655.  
  656. ------------------------------
  657.  
  658. From: -IX-  How, in Tcl, can I XXX:
  659. Subject: -Q9J- get or set an environment variable?
  660.  
  661. A9J. By using something like the following.
  662.  
  663. set olddisplay $env(DISPLAY)
  664. set env(DISPLAY) unix:0
  665.  
  666. Thanks to "Joel Fine" <joel@cs.berkeley.edu> for the answer.
  667.  
  668. ------------------------------
  669.  
  670. From: -IX-  How, in Tcl, can I XXX:
  671. Subject: -Q9K- use numbers with leading zeroes?
  672.  
  673. A9K. Dave Morriss was recently having problems because he was trying
  674. to do something like:
  675.  
  676. set index [expr [exec date +%W]%[llength $pop_server_list]]
  677.  
  678. but during the 9th and 9th week of the year, he got errors - 08 and 09
  679. are not valid octal numbers in Tcl.
  680.  
  681. Some of the solutions provided were:
  682.  
  683. From George A. Howlett <george.howlett@att.com>, we got:
  684.  
  685. set wknum [format "%g" [exec date +%W]]
  686. set index [expr [exec $wknum%[llength $pop_server_list]]
  687.  
  688. From Fred Feirtag <feirtag@wave.nrl.navy.mil> :
  689.  
  690. set index [expr (1[exec date +%W]-100)%[llength $pop_server_list]]
  691.  
  692. From Dan R. Schenck <schendr@Texaco.COM>:
  693.  
  694. set index [expr [string trimleft [exec date +%W] 0]%[llength $pop_server_list]]
  695.  
  696. ------------------------------
  697.  
  698. From: -IX-  How, in Tcl, can I XXX:
  699. Subject: -Q9L- find the command line arguments to my application?
  700.  
  701. A9L.  If you are using extended Tcl or Expect, you will find the parameters in
  702. the Tcl variable argv as a list.  Note that in extended Tcl, the name of 
  703. the program is in the Tcl variable programName and NOT in argv[0].  Thanks to
  704. brad@NeoSoft.com (Brad Morrison) and bachww@rtsg.mot.com (Bud Bach) for
  705. this answer.
  706.  
  707. ------------------------------
  708.  
  709. From: -IX-  How, in Tcl, can I XXX:
  710. Subject: -Q9M- put comments in my script, for example in a case statement?
  711.  
  712. A9M. You can't have comments where you have them.  Move the comments inside
  713. of the "{" for the case that you want.  Your code should read:
  714.  
  715. case 1 {
  716.   -1    {
  717.         #
  718.         # Cannot find information sought
  719.         #
  720.         exit 2
  721.         }
  722.    0    {
  723.         #
  724.         # Error in arguments
  725.         #
  726.         exit 1
  727.         }
  728.    default    {
  729.         #
  730.         # Desired information found
  731.         #
  732.         exit 0
  733.         }
  734. }
  735.  
  736. Thanks to gwlester@cpu.com (Gerald W. Lester).
  737.  
  738. ------------------------------
  739.  
  740. From: -IX-  How, in Tcl, can I XXX:
  741. Subject: -Q9N- redirect stdin or stdout safely, including binary data?
  742.  
  743. A9N. With Extended Tcl you can safely do stuff like:
  744.  
  745.         set infp [open "|compress -dc $fileName"]
  746.         set outfp [open "|gzip -c $newFileName" w]
  747.  
  748.         copyfile $infp $outfp
  749.  
  750. Thanks to karl@NeoSoft.com (Karl Lehenbauer) for the code example.
  751.  
  752. ------------------------------
  753.  
  754. From: -IX-  How, in Tcl, can I XXX:
  755. Subject: -Q9O- trap signals, and other more Unix specific functions?
  756.  
  757. A9O. Extended Tcl offers many of these types of functions.  For instance,
  758. extended Tcl has the 'signal' command:
  759.  
  760.         signal action siglist [command]
  761.  
  762.         where action is one of "default", "ignore", "error", "trap", "get",
  763.         plus the POSIX "block" and "unblock" actions (available only on
  764.         POSIX systems, of course).  Siglist is a list of either the symbolic
  765.         or numeric Unix signal (the SIG prefix is optional).  Command is your
  766.         error handler (or a simple {puts stdout "Don't press *that* key!"}  :-)
  767.  
  768. "trap" does what you expect, and I find "error" and "get" to be
  769. extremely useful in interactive programs which demand keyboard
  770. traversal.
  771.  
  772. Extended Tcl also has things like fork, etc.
  773.  
  774. Answer by brad@NeoSoft.com (Brad Morrison).
  775.  
  776. ------------------------------
  777.  
  778. From: -X-  How, in Tcl, can I XXX:
  779. Subject: -Q9P- get quoted strings to work the way I want?
  780.  
  781. A long article dealing with the issues can be found at
  782. ftp://harbor.ecn.purdue.edu/pub/tcl/docs/README.programmer
  783.  
  784. Here are some short answers:
  785.  
  786. Q. I'm trying to build up a command for later execution but am
  787. having trouble with variable values that include whitespace
  788. or special characters.
  789.  
  790. A. The safest way to build up commands is to use the list command
  791. so that you can keep track of the list structure.  Avoid using
  792. double quotes because you can end up with an extra trip through
  793. the evaluator.  We'll illustrate this with a command to create
  794. a button that prints out the label on the button when you click it.
  795.     Wrong answer #1:
  796.     button $myname -text $label -command "puts stdout $label"
  797.     Why? because if $label has whitespace then the puts command will
  798.     be passed the wrong number of arguments.  If $label has $ or [ ]
  799.     characters, they will be interpreted instead of printed.
  800.     Good answer #2:
  801.     button $myname -text $label -command [list puts stdout $label]
  802.     Why? because list will properly quote the value of $label
  803.  
  804. Q. I'm trying to build up a command for later execution but am
  805. having trouble getting some variables to evaluate now, and some
  806. to evaluate later when the command is run.
  807.  
  808. A. The cleanest way to do this is to define a procedure that hides
  809. the use of the variables at run time, and then build up a call to
  810. that procedure using the list command as described previously.  (You
  811. can even define the procedure on the fly.  It will have global scope
  812. even it if is created within another procedure.)
  813.     Wrong answer #1:
  814.     button $myname -text $label -command \
  815.         [list puts stdout $ArrayOfDynamicStuff($label)]
  816.     Why? The array value will be substituted when the button is created,
  817.     not later on when the button is clicked.  Also, note that the
  818.     command is executed at the global scope, so it is not necessary
  819.     to include a "global ArrayOfDynamicStuff" in the command.
  820.     Wrong answer #2 (backquotes and list):
  821.     button $myname -text $label -command \
  822.         [list puts stdout \$ArrayOfDynamicStuff($label)]
  823.     Why? Here the list command and the backquote of $ are fighting with
  824.     each other.  The command ends up being something like:
  825.         puts stdout {$ArrayOfDynamicStuff(foo)}
  826.     which prevents the substitution of the value of the array element.
  827.     Dubious answer #3 (backquotes and double-quotes):
  828.     button $myname -text $label -command \
  829.         "puts stdout \$ArrayOfDynamicStuff($label)"
  830.     Why? This only works if the value of $label has no special characters
  831.     or whitespace.
  832.     Clean answer #4 (proc):
  833.     proc doit { i } {
  834.         global ArrayOfDynamicStuff
  835.         puts stdout $ArrayOfDynamicStuff($i)
  836.     }
  837.     button $myname -text $label -command [list doit $label]
  838.     Why? Using little TCL procs for your button commands is a good habit
  839.     because it eliminates most needs for fancy quoting, and it
  840.     makes it easier to tweak the button command later on.
  841.  
  842. Q. I'm trying to pass along a variable number of args to another procedure
  843. but I'm having trouble getting the $args to expand right.
  844.  
  845. A. Avoid using eval and double quotes because that results in
  846. an extra trip through the interpreter.  The eval command will do
  847. a concat of its arguments if there are more than one, so that
  848. pretty much eliminates the need to group things with double quotes.
  849. Let's extend the button example:
  850.     Wrong answer #1:
  851.     proc mybutton { myname label args } {
  852.         button $myname -text $label -command [list puts stdout $label] $args
  853.     }
  854.     Why? All the extra arguments to mybutton are grouped into one list element
  855.     that is but into the value of $args.  However, the button command
  856.     expects to see individual arguments, not a sub-list.
  857.     Wrong answer #2:
  858.     proc mybutton { myname label args } {
  859.         eval "button $myname -text $label -command [list puts stdout $label] $args"
  860.     }
  861.     Why? The double quotes allow expansion of $label as well as $args, so if
  862.     $label has any whitespace, the button command will be malformed
  863.     Good answer #3:
  864.     proc mybutton { myname label args } {
  865.         set cmd {button $myname -text $label -command [list puts stdout $label]}
  866.         eval $cmd $args
  867.     }
  868.     Why? Eval will first concatenate its two arguments and then run the
  869.     result through the interpreter.  Think of this as stripping off the
  870.     outer curly braces from $cmd and $arg and making a single list
  871.     with all the elements of both.  $label will be evaluated exactly
  872.     once, so the puts command will remain good, and whatever went into
  873.     args will also be processed exactly one time.
  874.  
  875. Q. Why do I get a syntax error in an if/while/for statement?
  876. A. You may have written something like
  877.     wish: set foo bar
  878.     wish: if {$foo == bar} {puts stdout bar}
  879.     syntax error in expression "$foo == bar"
  880.  
  881. in which bar is interpreted as neither a string nor a variable, since
  882. strings as operands in expressions MUST be surrounded by double quotes
  883. or braces. 
  884.  
  885. Change to
  886.     wish: if {$foo == "bar"} {puts stdout bar}
  887. or
  888.     wish: if {$foo == {bar}} {puts stdout bar}
  889.  
  890. always in expressions, depending on if you want expansion performed or
  891. not. 
  892.  
  893. Contributed by "Jesper Blommaskog" <d9jesper@dtek.chalmers.se>
  894.  
  895. ------------------------------
  896.  
  897. From: -X-  How, in Tcl, can I XXX:
  898. Subject: -Q9Q- share procedures between multiple tcl applications?
  899.  
  900. A9Q.  Rather than sourcing the files explicitly, build a tcl library:
  901.  
  902. Step 1.  Put the files in a common directory
  903.  
  904. Step 2.  Build the tclIndex for the "library".  I use a Makefile with
  905. a convention like:
  906.  
  907. install.index:
  908.         (cd ${DESTDIR}/tclscripts/lib; \
  909.         echo 'source /usr/local/lib/tcl/init.tcl;\
  910.      auto_mkindex . *.tk' | tcl ; exit 0)
  911.  
  912. Step 3. Modify your tcl scripts to reference the library:
  913.  
  914. e.g.:
  915.  
  916. # local additions
  917. lappend auto_path /usr/local/lib/tcl_local $env(RDS_TCL_SCRIPTS)/lib
  918.  
  919. Now, as soon as your script tried to reference a procedure in the library,
  920. the "unknown" command autoloads the procedure for you.
  921.  
  922. Contributed by Joe VanAndel <vanandel@ncar.ucar.edu>
  923.  
  924.  
  925. ------------------------------
  926.  
  927. From: -X-  How, in Tk, can I XXX:
  928. Subject: -Q9R- get items inserted into a list?
  929.  
  930. A9R.  A user asked why
  931.  
  932.     linsert $list 0 ..
  933.  
  934. did not result in .. being inserted into list.
  935.  
  936. d9jesper@dtek.chalmers.se (Jesper Blommaskog) replied:
  937.  
  938. When doing list operations other than lappend, you must save the
  939. returned value. This applies to list, lindex, lrange, lreplace at
  940. least.
  941.  
  942. In this example, you would perhaps want to do something like:
  943.  
  944.     set list [ linsert $list 0 .. ] 
  945.  
  946. ------------------------------
  947.  
  948. From: -X-  How, in Tk, can I XXX:
  949. Subject: -Q9S- perform a non-blocking read on a file identifier?
  950.  
  951. A9S.  From Frank Smith <frank@arraysystems.nstn.ns.ca> we are told that
  952. if you have Extended Tcl, you can
  953.  
  954.    read $fileId [fstat $fileId size]
  955.  
  956. This will read only the number of bytes currently available on 'fileId'
  957. and consequently will not block.
  958.  
  959. ------------------------------
  960.  
  961. From: -X-  How, in Tk, can I XXX:
  962. Subject: -Q9T- read and write from a pipe without locking up?
  963.  
  964. A9T. The stdio package has an optimization for speed that buffers characters so 
  965. that you can avoid un-necessary system calls. This isn't very good for 
  966. interactive use so stdio changes it's behaviour if the file is a terminal. When 
  967. you write to a pipe you are not writing to a terminal and so your output is 
  968. buffered, similarly when the program at the other end of the pipe writes its 
  969. response it is also buffered. The end result is the programs at both end of the 
  970. pipe stall waiting for input. It is possible to force the buffers to be written 
  971. using flush in Tcl and fflush() in C, often though, you don't have control over 
  972. the program at the other end of the pipeline and in that case your only 
  973. solution is to use a pseudo-teletype (pty). Unfortunately this isn't all that 
  974. easy.
  975.  
  976. While this isn't directly supported in Tcl the spawn command in expect opens a 
  977. pty and starts a command.
  978.  
  979.  
  980. ------------------------------
  981.  
  982. From: -X-  How, in Tk, can I XXX:
  983. Subject: -Q10.A.1- get my wish application to execute - I just get a
  984.         wish prompt!  Or I just get error msgs about permission
  985.         denied, not found, etc.
  986.  
  987. A10.A.1. Most systems require a full pathname to the interpreter.  
  988. So you cannot start a wish script out as 
  989.  
  990. #! wish -f
  991.  
  992. Likewise, many Unix systems have a maximum length of characters that you can
  993. put on a #! line.  If you exceed this, you do not get the behaviour you
  994. expect.  So do not try to put something like:
  995.  
  996. #! /projects/somethingbig/bin/sun4/wish -f
  997.  
  998. followed by your wish code.  Keep the lines short - under 32 characters is
  999. recommended.
  1000.  
  1001. Finally, on some machines, white space after the -f causes a problem.  Be
  1002. sure that the -f are the last characters on the first line of the file.
  1003.  
  1004. ------------------------------
  1005.  
  1006. From: -X-  How, in Tk, can I XXX:
  1007. Subject: -Q10.A.2- ,using a machine with less than 8 bit color, run?
  1008.  
  1009. A10.A.2. Tk doesn't behave very well with less than 8-bit color screens.  To
  1010. try to use it, find all the places in the Tk/wish source where 
  1011. DefaultDepthOfScreen is invoked to test the number of bit-planes.  Change all
  1012. of these to pretend there is just 1 bit-plane, or call a procedure which
  1013. monitors a Tcl variable so that it is configurable, and you should be okay.
  1014.  
  1015. Another alternative is to see if the server you are using has alternative
  1016. visual / color models, such as static visual, etc.  One of the alternatives
  1017. may allow Tk to work better.
  1018.  
  1019. Thanks to "Nathaniel Borenstein" <nsb@thumper.bellcore.com> for this info!
  1020.  
  1021. ------------------------------
  1022.  
  1023. From: -X-  How, in Tk, can I XXX:
  1024. Subject: -Q10.A.3- set X11 resources for a wish application in an 
  1025.         app-defaults file?
  1026.  
  1027. A10.A.3. Read the documentation for the option command.
  1028. Then you should consider something like the following - assume the program
  1029. name is xwf.
  1030.  
  1031. The following are two general purpose functions to put into a library:
  1032.  
  1033. # envVal envValName
  1034. #   Looks up the envValName environment variable and returns its
  1035. #   value, or {} if it does not exists
  1036. proc envVal {envValName} {
  1037.   global env
  1038.   if [info exists env($envValName)] {return $env($envValName)} {return {}}
  1039. }
  1040.  
  1041. # loadAppDefaults classNameList ?priority?
  1042. #   Searches for the app-default files corresponding to classNames in
  1043. #   the order specified by X Toolkit Intrinsics, and loads them with
  1044. #   the priority specified (default: startupFile).
  1045. proc loadAppDefaults {classNameList {priority startupFile}} {
  1046.   set filepath "[split [envVal XUSERFILESEARCHPATH] :] \
  1047.         [envVal XAPPLRESDIR] \
  1048.         [split [envVal XFILESEARCHPATH] :] \
  1049.         /usr/lib/X11"
  1050.   foreach i $classNameList {
  1051.     foreach j $filepath {
  1052.       if {[file exists $j/$i]} {
  1053.     option readfile $j/$i $priority; break
  1054.       }
  1055.     }
  1056.   }
  1057. }
  1058.  
  1059. # Now, here is what you would put into xwf:
  1060.  
  1061. option add Tk.BoldFont "*-lucida sans-Bold-R-Normal-*-100-*" widgetDefault
  1062. loadAppDefaults {xwf XWF} userDefault
  1063.  
  1064. This sets a program default, then load any defaults specified in the user's
  1065. default resources and finally any site or general app-defaults resource.  
  1066. Of course, you would want to add some xwf command line handling to allow 
  1067. the user to override things at execution time.
  1068.  
  1069. ------------------------------
  1070.  
  1071. From: -X-  How, in Tk, can I XXX:
  1072. Subject: -Q10.A.4- specify bitmap patterns on the command line instead of 
  1073.         just as a file name?
  1074.  
  1075. A10.A.4. You can not, at least as of June, 1992.
  1076.  
  1077. ------------------------------
  1078.  
  1079. From: -X-  How, in Tk, can I XXX:
  1080. Subject: -Q10.A.5- get a Motif user interface?
  1081.  
  1082. A10.A.5. Tk does not currently use the Xt toolkit, so a strict adherence
  1083. to Motif via the libXm.a routines is not possible.  However, the authors
  1084. of Tk prefer the Motif style of user interface, so you will find that Tk
  1085. makes quite an attempt to implement a Motif-like interface.
  1086.  
  1087. ------------------------------
  1088.  
  1089. From: -X-  How, in Tk, can I XXX:
  1090. Subject: -Q10.A.6- get an OpenLook user interface?
  1091.  
  1092. A10.A.6. Unfortunately, Tk does not currently use either XView or Xt based
  1093. widgets in its user interface, so an OpenLook compliant (or even
  1094. similar) interface is probably not easily achievable in the near future.
  1095.  
  1096. ------------------------------
  1097.  
  1098. From: -X-  How, in Tk, can I XXX:
  1099. Subject: -Q10.A.7- get Tk 3.3 to even start - I get security error messages.
  1100.  
  1101. A10.A.7.  Alternate forms of this question often mention that Tk 3.3 send
  1102. is broken, or ask how to use xauth.
  1103.  
  1104. Under Tk 3.3, the X11 xauth security mechanism is used.  While this
  1105. provides more security, it does require the user to do a bit more
  1106. setup.  The user needs to create an Xauthority file (typically
  1107. $HOME/.Xauthority) and then restart the X server with the
  1108. -auth argument, along with the name of the Xauthority file created.
  1109. Read the X11 documentation for your system for the details on how to
  1110. use xauth or comparable software to create the authority files needed.
  1111. An intro to xauth is available as
  1112. ftp://harbor.ecn.purdue.edu/pub/tcl/docs/Xauthority .
  1113.  
  1114. Also note that you can configure Tk to not depend on xauth by modifying
  1115. the tk3.3/Makefile.in to comment out the following:
  1116.  
  1117. # To turn off the security checks that disallow incoming sends when
  1118. # the X server appears to be insecure, reverse the comments on the
  1119. # following lines:
  1120. #SECURITY_FLAGS =
  1121. SECURITY_FLAGS = -DTK_NO_SECURITY
  1122.  
  1123. ------------------------------
  1124.  
  1125. From: -X-  How, in Tk, can I XXX:
  1126. Subject: -Q10.B.1- change the default class bindings?
  1127.  
  1128. A10.B.1. All default class bindings for Tk widgets are initialized in
  1129. $tk_library/tk.tcl.  Use this file as a guide to implement new
  1130. bindings.  For instance, the following code duplicates Button 1's
  1131. drag-select facility in Button 3 for all listboxes:
  1132.  
  1133. bind Listbox <3> {%W select from [%W nearest %y]}
  1134. bind Listbox <B3-Motion> {%W select to [%W nearest %y]}
  1135.  
  1136. ------------------------------
  1137.  
  1138. From: -X-  How, in Tk, can I XXX:
  1139. Subject: -Q10.B.2- delete a binding?
  1140.  
  1141. A10.B.2. Give an empty-string command to the "bind" invocation.  For
  1142. example, to disable the Delete key in all entry fields:
  1143.  
  1144.     bind Entry <Delete> {}
  1145.  
  1146. ------------------------------
  1147.  
  1148. From: -X-  How, in Tk, can I XXX:
  1149. Subject: -Q10.B.3- change a binding while it is being executed?
  1150.  
  1151. A10.B.3. As of June, 1992, this was not a safe thing to do in Tk.  It was
  1152. put on the bug list by John Ousterhout to be fixed in a future version.
  1153.  
  1154. The solution for now is not to change the bindings, but to change
  1155. something in the code they execute.  For example, keep a state variable
  1156. that indicates which binding you'd like, but always have the binding
  1157. call a given procedure.  Then that procedure checks the variable and
  1158. executes one piece of code or another.  Or, you could just make the
  1159. binding's command "eval $cmd" and then change the variable "cmd"
  1160. depending on your application's state.
  1161.  
  1162. ------------------------------
  1163.  
  1164. From: -X-  How, in Tk, can I XXX:
  1165. Subject: -Q10.B.4- bind the arrow key on my Sun keyboard?
  1166.  
  1167. A10.B.4. You have to call it <Left> rather than <R10>.  Under X11, keys are
  1168. referred to by their keysym.  One can use either xmodmap -pk or the xev
  1169. program to determine what the keysym a particular key on a keyboard is
  1170. currently generating.
  1171.  
  1172. If the keysym that is being used is not known by Tk, you may have to edit
  1173. its ks_names.h file.  There is a note in this file that indicates that
  1174. one should not edit it - but this is where the keysym must be for it to
  1175. be recognized.
  1176.  
  1177. Thanks to Wayne Christopher <faustus@CS.Berkeley.EDU> for this
  1178. note.
  1179.  
  1180. ------------------------------
  1181.  
  1182. From: -X-  How, in Tk, can I XXX:
  1183. Subject: -Q10.B.5- get root's mouse bindings to work in my Tk application?
  1184.  
  1185. A10.B.5. Some window managers, such as mwm, define mouse button bindings
  1186. which cause Tk some problems.  Try saving off the window manager's startup
  1187. file (something like /.mwmrc for instance) and then copy in a startup
  1188. file from a login id that works.  Thanks to brad@NeoSoft.com (Brad Morrison)
  1189. for this invaluable tip!
  1190.  
  1191. ------------------------------
  1192.  
  1193. From: -X-  How, in Tk, can I XXX:
  1194. Subject: -Q10.C.1- get an application to also use libXt?
  1195.  
  1196. A10.C.1. Tk2.1 and Xt have different X connections, and XtAppNextEvent will
  1197. block is there is nothing coming from the X connection.  One way
  1198. of fixing this is get the connection number of Tk using
  1199.  
  1200.    ConnectionNumber(Tk_Display(tk_window));
  1201.  
  1202. and using XtAddInput to register this with the Xt event handler.  The
  1203. callback procedure for XtAddInput wrapper procedure that runs
  1204. Tk_OneEvent(1).  There might be problems with Tk file sources which
  1205. aren't registered with Xt.
  1206.  
  1207. Thanks to joe@astro.as.utexas.edu (Joe Wang) for this information.
  1208.  
  1209. ------------------------------
  1210.  
  1211. From: -X-  How, in Tk, can I XXX:
  1212. Subject: -Q10.C.2- change the X11 cursor?
  1213.  
  1214. A10.C.2. Here is a tip from mgc@cray.com (M. G. Christenson).
  1215.  
  1216. Look at /usr/include/X11/cursorfont.h for a list of available cursors.
  1217. You can use the names in there by removing the 'XC_'.  
  1218.  
  1219. Here's a little proc I use to make my entire application go 'busy'
  1220. while it's doing something. Just call it with the commands you want to
  1221. execute, and the watch cursor will be displayed for the time it takes
  1222. the commands to complete.  Note that any new windows will have their
  1223. normal cursor.
  1224.  
  1225. proc busy {cmds} {
  1226.     global errorInfo
  1227.  
  1228.     set busy {.app .root}
  1229.     set list [winfo children .]
  1230.     while {$list != ""} {
  1231.     set next {}
  1232.     foreach w $list {
  1233.         set class [winfo class $w]
  1234.         set cursor [lindex [$w config -cursor] 4]
  1235.         if {[winfo toplevel $w] == $w || $cursor != ""} {
  1236.         lappend busy [list $w $cursor]
  1237.         }
  1238.         set next [concat $next [winfo children $w]]
  1239.     }
  1240.     set list $next
  1241.     }
  1242.  
  1243.     foreach w $busy {
  1244.     catch {[lindex $w 0] config -cursor watch}
  1245.     }
  1246.  
  1247.     update idletasks
  1248.  
  1249.     set error [catch {uplevel eval [list $cmds]} result]
  1250.     set ei $errorInfo
  1251.  
  1252.     foreach w $busy {
  1253.     catch {[lindex $w 0] config -cursor [lindex $w 1]}
  1254.     }
  1255.  
  1256.     if $error {
  1257.     error $result $ei
  1258.     } else {
  1259.     return $result
  1260.     }
  1261. }
  1262.  
  1263. ------------------------------
  1264.  
  1265. From: -X-  How, in Tk, can I XXX:
  1266. Subject: -Q10.C.3- raise or lower a window?
  1267.  
  1268. A10.C.3. This is on the (semi-infinite) list of things to be done in the future.
  1269. If you have the time, please go ahead and add it and submit the code and all
  1270. will be grateful.
  1271.  
  1272. ------------------------------
  1273.  
  1274. From: -X-  How, in Tk, can I XXX:
  1275. Subject: -Q10.C.4- re-map a withdrawn window id?
  1276.  
  1277. A10.C.4. Use wm deiconify <windowid>.
  1278.  
  1279. ------------------------------
  1280.  
  1281. From: -X-  How, in Tk, can I XXX:
  1282. Subject: -Q10.C.5- use Tk in a subwindow of a non-Tk X11 application?
  1283.  
  1284. A10.C.5. From faustus@CS.Berkeley.EDU (Wayne A. Christopher):
  1285.  
  1286. [C]reate the Tk toplevel window but don't map it (wm withdraw).  Then
  1287. re-parent the window to be a subwindow of your other one and then map
  1288. it.  I have done this when the Tk application is a separate process,
  1289. but if it's the same process I think you will get into trouble with the
  1290. event loop, since each toolkit wants control.
  1291.  
  1292. ------------------------------
  1293.  
  1294. From: -X-  How, in Tk, can I XXX:
  1295. Subject: -Q10.C.6- bind <Enter> and <Leave> to a frame containing 
  1296.     other widgets?
  1297.  
  1298. A10.C.6. From John Ousterhout, ouster@cs.Berkeley.EDU):
  1299.  
  1300. Each <Enter> or <Leave> event has a "detail" field, which you can access
  1301. from bindings with "%d".  If the detail is "NotifyInferior" it means the
  1302. pointer has moved into or out of a child window (so it's really still in
  1303. the area of the window receiving the event).  You should be able to check
  1304. the detail in your scripts and ignore events with a detail of NotifyInferior.
  1305. Check the Xlib documentation for Enter/Leave events for complete
  1306. information on the detail field.
  1307.  
  1308.  
  1309. ------------------------------
  1310.  
  1311. From: -X-  How, in Tk, can I XXX:
  1312. Subject: -Q10.C.7- mix interactions between Xt and Tk/Tcl?
  1313.  
  1314. A10.C.7.
  1315.  
  1316. [From YIP Chi Lap [Beta] <h9118101@hkuxa.hku.hk> ]
  1317.     I have come up with a CPU hogging polling loop that
  1318. works (till now) for my application which not much
  1319. direct interaction between a Tk window and an Xt window is made.
  1320. (e.g., it won't draw something on a Tk window by a Xt-dispatched routine)
  1321.  
  1322.   XEvent xevent;
  1323.   for (;;)
  1324.   {
  1325.     if (XtAppPending(appcontext))
  1326.     {
  1327.       XtAppNextEvent(appcontext,&xevent);
  1328.       XtDispatchEvent(&xevent);
  1329.     }
  1330.     Tk_DoOneEvent(TK_DONT_WAIT);
  1331.   }
  1332.  
  1333. [ From David C Mudie <mudie@radon.eecs.berkeley.edu> ]
  1334.     We use the main event loop below.  The basic idea
  1335. is to watch for events arriving from either the Xt server
  1336. connection or the Tk server connection and then call
  1337. the library dispatchers.
  1338.  
  1339.     The code fragment below will need to be cleaned up for
  1340. your usage; there are some missing include statements
  1341. and global declarations buried elsewhere in the file.
  1342.  
  1343. /* Allow Tcl/Tk and Xt to work at the same time. */
  1344. void tkGo(void)
  1345. {
  1346.   extern Widget topLevel;
  1347.   int width = ulimit(4, -1);
  1348.   fd_set readfds;
  1349.   struct timeval timeout;
  1350.   int nfds;
  1351.   int tkfd = ConnectionNumber(Tk_Display(mainWindow));
  1352.   int xtfd = ConnectionNumber(XtDisplay(topLevel));
  1353.  
  1354.   Tcl_VarEval(interp, "update", NULL);
  1355.   while (1) {
  1356.  
  1357.     /* Select on X server connections to wait for event. */
  1358.     /* Timeout every half second to allow processing of non-X events */
  1359.  
  1360.     FD_ZERO(&readfds);
  1361.     FD_SET(tkfd, &readfds);
  1362.     FD_SET(xtfd, &readfds);
  1363.     timeout.tv_sec = 0;
  1364.     timeout.tv_usec = 500000;
  1365.  
  1366.     nfds = select(width, &readfds, NULL, NULL, &timeout);
  1367.     if (nfds < 0 && errno != EINTR) {
  1368.       perror("select");
  1369.     } else if (nfds == 0) {
  1370.       /* printf("timeout\n"); */
  1371.     }
  1372.  
  1373.     while (XtPending()) {
  1374.       XtProcessEvent(XtIMAll);
  1375.     }
  1376.  
  1377.     while (Tk_DoOneEvent(1)) {
  1378.       /* do nothing */
  1379.     }
  1380.   
  1381.     if (mainWindow == NULL) {
  1382. //      Tcl_DeleteInterp(interp);
  1383. //      Tcl_DStringFree(&command);
  1384.       Tcl_Eval(interp, "exit");
  1385.       return;
  1386.     }
  1387.   }
  1388. }
  1389.  
  1390. [ From Davide Frisoni <frisoni@faw.uni-ulm.de> ]
  1391.     One may use Xt properties to communicate between different
  1392. applications.
  1393.  
  1394.  
  1395. ------------------------------
  1396.  
  1397. From: -X-  How, in Tk, can I XXX:
  1398. Subject: -Q10.D.1- resize a listbox?
  1399.  
  1400. A10.D.1. Use wm min/maxsize - in a uniform manner.  Here is a resizable listbox:
  1401.  
  1402.         #!/usr/local/bin/wish -f
  1403.         wm minsize . 20 20
  1404.         wm maxsize . 1152 900
  1405.         pack append . [listbox .l -borderwidth 2 -relief raised] {expand fill}
  1406.  
  1407. Doing the same with the text widget brings its resizing under control too.
  1408.  
  1409. Thanks to "John C Ellson" <ellson@ontap.att.com).
  1410.  
  1411. ------------------------------
  1412.  
  1413. From: -X-  How, in Tk, can I XXX:
  1414. Subject: -Q10.D.2- select two items that are not adjacent in the listbox at 
  1415.         one time?
  1416.  
  1417. A10.D.2.  See Marc R. Ewing's Listbox.patch for a way to modify Tk to allow
  1418. selection of non-contiguous entries.
  1419.  
  1420. ------------------------------
  1421.  
  1422. From: -X-  How, in Tk, can I XXX:
  1423. Subject: -Q10.D.3- select items in more than one Tk listbox at a time?
  1424.  
  1425. A10.D.3. The default for Tk's listbox widget exports its selection as the
  1426. X selection.  There can only be one of these at a time.
  1427.  
  1428. To turn off this behavior in Tk, use the -exportselection false when
  1429. you create the listbox.  Or, use the
  1430.  
  1431. option add *Listbox.exportselection false
  1432.  
  1433. command in the beginning of your script.
  1434.  
  1435. Thanks to David Herron <david@davids.mmdf.com> for this tip.
  1436.  
  1437. ------------------------------
  1438.  
  1439. From: -X-  How, in Tk, can I XXX:
  1440. Subject: -Q10.D.4- avoid fractional white space at the end of a resizable
  1441.         listbox?
  1442.  
  1443. A10.D.4. First, let's state the problem more clearly. I want to make a
  1444. resizable listbox and I don't want to constrain it by setting a
  1445. minimum size. So I pack it with fill expand, I use it to set the grid
  1446. (so that resizing the window always gives me whole lines) and I set an
  1447. initial geometry of 1x1 to override the default. However what I get
  1448. is... (run the code below for a demo and try to resize)
  1449.  
  1450. listbox .l -geom 1x1 -setgrid 1 -yscrollcommand ".s set" -relief sunken -bd 2
  1451. scrollbar .s -command ".l yview"
  1452. pack .s -side right -fill y
  1453. pack .l -side top -fill both -expand 1
  1454. .l insert end one two three four five six seven eight nine ten "THE END"
  1455.  
  1456. ...a situation where the partially filled listbox has a blank
  1457. half-line at the bottom even if there are more items in the list. This
  1458. is very confusing because it fools the user into thinking that there
  1459. is nothing else beyond what's visible. Why does it happen?
  1460.  
  1461. Now for the answer.
  1462.     Look at the window as it is created, before the resizing. See that
  1463. poor, tiny little scrollbar squeezed in that microscopic window? It,
  1464. too, requests a minimum size, and it so happens that the starting
  1465. geometry for the listbox (i.e. the situation referred to as "1x1")
  1466. receives some free fractional space at the bottom. And you never get
  1467. rid of it, since the resizing is constrained to be in whole
  1468. characters.
  1469.  
  1470. The thing to do is to define the initial layout in such a way that the
  1471. widget that has -setgrid actually displays an integer number of lines
  1472. and columns. In the above example, setting -geom 1x2 does the trick.
  1473.  
  1474. Thanks to Frank Stajano <fms@cam-orl.co.uk> for this tip.
  1475.  
  1476. ------------------------------
  1477.  
  1478. From: -X-  How, in Tk, can I XXX:
  1479. Subject: -Q10.E.1- get output from a Tk canvas?
  1480.  
  1481. A10.E.1. The latest Tk has a save suboption on canvas which allows one
  1482. to create a file describing the canvas.  The default output is Encapsulated
  1483. Postscript, but there is an xpm3 suboption as well.
  1484.  
  1485. ------------------------------
  1486.  
  1487. From: -X-  How, in Tk, can I XXX:
  1488. Subject: -Q10.E.2- fill a canvas which is bounded by lines as opposed to a
  1489.         shape like a polygon, oval, etc.?
  1490.  
  1491. A10.E.2. No, you have to at least use a polygon if you want to fill an area
  1492. bounded by some lines.
  1493.  
  1494. ------------------------------
  1495.  
  1496. From: -X-  How, in Tk, can I XXX:
  1497. Subject: -Q10.E.3- raise/lower canvas window objects or draw graphics onto a 
  1498.         window object inside a canvas?
  1499.  
  1500. A10.E.3. You can't yet. 
  1501.  
  1502. "Jesper Blommaskog" <d9jesper@dtek.chalmers.se>.
  1503.  
  1504. ------------------------------
  1505.  
  1506. From: -X-  How, in Tk, can I XXX:
  1507. Subject: -Q10.E.4- detect when the canvas has been resized?
  1508.  
  1509. A10.E.4. From Nathaniel Pryce <np@hpl.hp.co.uk>:
  1510.  
  1511. > I have a window with a canvas containing some stuff that logically
  1512. > fills the canvas (say, a chess board or a map of the world). I want
  1513. > this toplevel window to be resizable and of course, when the win is
  1514. > resized, I want the stuff inside the canvas to be scaled
  1515. > accordingly. Now, I can manage the scaling of the stuff, but what
  1516. > I'm having trouble with is DETECTING that I should do it. How can I
  1517. > be notified that the window has been resized?
  1518.  
  1519. Nat's answer is:
  1520.  
  1521. You need to bind a command to the Configure event, like this:
  1522.  
  1523.     proc config {w h} {
  1524.        puts stdout ".canvas - width = $w, height = $h"
  1525.     }
  1526.  
  1527.     bind .canvas <Configure> "config %w %h"
  1528.  
  1529.  
  1530. .canvas - width = 224, height = 251
  1531. .canvas - width = 224, height = 151
  1532. .canvas - width = 224, height = 243
  1533. # and so forth
  1534.  
  1535. ------------------------------
  1536.  
  1537. From: -X-  How, in Tk, can I XXX:
  1538. Subject: -Q10.F.1- get the name of my own interpreter?
  1539.  
  1540. A10.F.1. george.howlett@att.com (George A. Howlett) points us to the winfo manual
  1541. page - winfo name . gets the name of the current application.
  1542.  
  1543. ------------------------------
  1544.  
  1545. From: -X-  How, in Tk, can I XXX:
  1546. Subject: -Q10.F.2- get -relief to work on my text widgets?
  1547.  
  1548. A10.F.2. From Owen Rees <rtor@ansa.co.uk>, we find out that we must:
  1549.  
  1550. "[m]ake the border width non-zero as in"
  1551.  
  1552.    text .t -width 20 -height 20 -relief sunken -borderwidth 4
  1553.  
  1554. ------------------------------
  1555.  
  1556. From: -X-  How, in Tk, can I XXX:
  1557. Subject: -Q10.F.3- create a scrollable window of buttons?
  1558.  
  1559. A10.F.3. There are at least two ways to do this.  First, there is a hypertext
  1560. widget that one can get from the Tcl User Contributed Code Archive -
  1561. (see "tcl-faq/part4") and (see "tcl-faq/part5") for details -
  1562.  which provides such a facility.
  1563.  
  1564. And here is some sample code from 
  1565. "Michael Moore" <mdm@stegosaur.cis.ohio-state.edu> which shows a way to 
  1566. do this using just Tk.
  1567.  
  1568. #! /bin/wish -f
  1569. #
  1570. # This demonstrates how to create a scrollable canvas with multiple
  1571. # buttons.
  1572. #
  1573. # Author : Michael Moore
  1574. # Date   : November 17, 1992
  1575. #
  1576.  
  1577. #
  1578. # This procedure obtains all the items with the tag "active"
  1579. # and prints out their ids.
  1580.  
  1581. proc multi_action {} {
  1582.     set list [.frame.canvas find withtag "active"]
  1583.     puts stdout "Active Item Ids : "
  1584.     foreach item $list {
  1585.     puts stdout $item
  1586.     }
  1587. }
  1588.  
  1589. # This simulates the toggling of a command button...
  1590. # Note that it only works on a color display as is right now
  1591. # but the principle is the same for b&w screens.
  1592. proc multi_activate {num id} {
  1593.     
  1594.     set tags [.frame.canvas gettags $id]
  1595.     if {[lsearch $tags "active"] != -1} {
  1596.     .frame.canvas dtag $id "active"
  1597.     .frame.canvas.button$num configure \
  1598.         -background "#060" \
  1599.         -activebackground "#080" 
  1600.     } else {
  1601.     .frame.canvas addtag "active" withtag $id
  1602.     .frame.canvas.button$num configure \
  1603.         -background "#600" \
  1604.         -activebackground "#800"
  1605.     }
  1606.  
  1607. proc setup {} {
  1608.      frame .frame
  1609.  
  1610.      scrollbar .frame.scroll \
  1611.          -command ".frame.canvas yview" \
  1612.          -relief raised
  1613.  
  1614.      canvas .frame.canvas \
  1615.          -yscroll ".frame.scroll set" \
  1616.          -scrollregion {0 0 0 650} \
  1617.          -relief raised \
  1618.      -confine false \
  1619.      -scrollincrement 25
  1620.  
  1621.      pack append .frame \
  1622.          .frame.scroll    {left frame center filly} \
  1623.          .frame.canvas    {left frame center fillx filly}
  1624.  
  1625.      pack append .\
  1626.          .frame   {left frame center fillx filly}
  1627.  
  1628.      button .frame.canvas.action  \
  1629.          -relief raised \
  1630.          -text "Action" \
  1631.      -command "multi_action"
  1632.      .frame.canvas create window 1 25 \
  1633.      -anchor w \
  1634.          -window .frame.canvas.action
  1635.      for {set i 2} {$i < 26} {incr i} {
  1636.      button .frame.canvas.button$i  \
  1637.         -relief raised \
  1638.         -background "#060" \
  1639.         -foreground wheat \
  1640.         -activebackground "#080" \
  1641.         -activeforeground wheat \
  1642.         -text "Button $i" 
  1643.      set id [.frame.canvas create window 1 [expr $i*25] \
  1644.         -anchor w \
  1645.         -window .frame.canvas.button$i]
  1646.      .frame.canvas.button$i configure \
  1647.         -command "multi_activate $i $id"
  1648.     }
  1649. }
  1650.  
  1651. setup
  1652.  
  1653. ------------------------------
  1654.  
  1655. From: -X-  How, in Tk, can I XXX:
  1656. Subject: -Q10.F.4- pack a text widget so that it can be resized interactively?
  1657.  
  1658. A10.F.4. From Spencer W. Thomas <spencer@med.umich.edu> we find that we need to:
  1659.  
  1660. wm minsize . 0 0
  1661. text .text
  1662. pack append . .text {fill expand}
  1663.  
  1664. ------------------------------
  1665.  
  1666. From: -X-  How, in Tk, can I XXX:
  1667. Subject: -Q10.F.5- create a widget with an upper case name?
  1668.  
  1669. A10.F.5. During a recent revision of Tk, things were changed so that names
  1670. beginning with a capital letter are reserved for class names.  Specific
  1671. instances of widgets must begin with a lower case letter.  This enables
  1672. X11 resource definitions to distinguish between a class and instance.
  1673.  
  1674. ------------------------------
  1675.  
  1676. From: -X-  How, in Tk, can I XXX:
  1677. Subject: -Q10.F.6- create equal sized buttons?
  1678.  
  1679. A10.F.6. Recently, Micael Salmon <etxmesa@eos.ericsson.se> posted:
  1680.  
  1681. In article <1993Jun23.065417.4302@ericsson.se>, I write:
  1682. |> I am currently working on yet another tn3270 emulator and I have run
  1683. |> into a problem with creating equal sized buttons. I have created an
  1684. |> array of buttons for PF and cursor keys and I would now like to make
  1685. |> them all the same size. Arranging them into columns was not
  1686. |> a problem but when I add bitmaps the buttons lose their horizontal
  1687. |> alignment. What I tried was to read the height and width of the buttons
  1688. |> using winfo, determine the largest and then use pads to force them to
  1689. |> be the same size, this doesn't seem to work. The technique of using
  1690. |> pre-set height and width doesn't seem applicable when using a mixture
  1691. |> of bitmaps and text as the size in pixels of a text button is font
  1692. |> dependent. All suggestions welcome.
  1693.  
  1694. Jim Wight <J.K.Wight@newcastle.ac.uk> suggested using reqheight and reqwidth
  1695. and then specifying padx and pady in the pack command for each button.
  1696. Jim says:
  1697. I think it only fair to point out that it was Tuomas J Lukka
  1698. <lukka@klaava.Helsinki.FI> who suggested the use of reqwidth and reqheight when I asked how to get over the deficiencies in my first attempt at a solution
  1699. that I posted to this group.
  1700.  
  1701. Since you're all agog I might as well post the final solution (more or less)
  1702. that I mailed to Michael.
  1703.  
  1704. frame .frame1
  1705. frame .frame2
  1706. button .frame1.a -text "pretty long button text"
  1707. button .frame1.b -text "short one"
  1708. button .frame2.c -bitmap "@/usr/include/X11/bitmaps/xlogo32"
  1709. button .frame2.d -text "tiny"
  1710.  
  1711. set long [winfo reqwidth .frame1.a]
  1712. set short [winfo reqwidth .frame1.b]
  1713. set medium [winfo reqwidth .frame2.c]
  1714. set tiny [winfo reqwidth .frame2.d]
  1715. set pady [expr [winfo reqheight .frame2.c]-[winfo reqheight .frame2.d]]
  1716.  
  1717. pack append .frame1 .frame1.a "filly pady $pady"
  1718. pack append .frame1 .frame1.b "fillx padx [expr $long-$short] filly pady $pady"pack append .frame2 .frame2.c "fillx padx [expr $long-$medium] filly"
  1719. pack append .frame2 .frame2.d "fillx padx [expr $long-$tiny] filly pady $pady"
  1720. pack append . .frame1 {left} .frame2 {left}
  1721.  
  1722.  
  1723. ------------------------------
  1724.  
  1725. From: -X-  How, in Tk, can I XXX:
  1726. Subject: -Q10.F.7- vertically stack radio buttons aligning regardless of font?
  1727.  
  1728. A10.F.7.  Till Brychcy <brychcy@informatik.tu-muenchen.de> provides
  1729. the following example:
  1730.  
  1731.  
  1732.     radiobutton .times -text Times -anchor w
  1733.     radiobutton .helvetica -text Helvetica -anchor w
  1734.     radiobutton .courier -text Courier -anchor w
  1735.     pack .times .helvetica .courier -side top -fill x
  1736.  
  1737. Note that you are using anchor west in the widgets themselves, and not in
  1738. the packer.  This lets the packer produce full width buttons.
  1739.  
  1740.  
  1741. ------------------------------
  1742.  
  1743. From: -X-  How, in Tk, can I XXX:
  1744. Subject: -Q10.F.8- initialize an entry widget with some text?
  1745.  
  1746. A10.F.8.  kesch@kappco.kapp-coburg.de (Peter Kesch) provides us with
  1747. one example:
  1748.  
  1749. set default "foobar"
  1750. entry .foo -width 25 -state disabled -textvariable default
  1751.  
  1752.  
  1753. ------------------------------
  1754.  
  1755.  
  1756. End of comp.lang.tcl Frequently Asked Questions (2/5)
  1757. *****************************************************
  1758. -- 
  1759. :s Great net resources sought...
  1760. :s Larry W. Virden                 INET: lvirden@cas.org
  1761. :s Personal: 674 Falls Place,   Reynoldsburg, OH 43068-1614
  1762. The task of an educator should be to irrigate the desert not clear the forest.
  1763. -- 
  1764. :s Great net resources sought...
  1765. :s Larry W. Virden                 INET: lvirden@cas.org
  1766. :s Personal: 674 Falls Place,   Reynoldsburg, OH 43068-1614
  1767. The task of an educator should be to irrigate the desert not clear the forest.
  1768.  
  1769.